/*==库引用======================*/
var express=require('express'),
	path=require("path"),
	bodyParser = require('body-parser'),
	compression=require('compression');
	// cookieParser = require('cookie-parser'),
	// session = require('express-session'),
	// RedisStore = require('connect-redis')(session);

/*==实例化====================*/
var app=express();

// 创建 application/x-www-form-urlencoded 编码解析
//var urlencodedParser = bodyParser.urlencoded({ extended: false });

/*==自主类引用================*/
var routes=require('./routes')(app);
//var config=require('./config');


/*==调用中间件使用=============*/
app.use(bodyParser.json());
app.use(compression()); 
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname,'public')));
//捕获并处理404
app.use(function(req, res, next) {
	res.status(404).send('抱歉，当前没有找到路径、文件。404 Not Frond');
});
// app.use(cookieParser());

//session设置
// app.use(session({
// 	store:new RedisStore(config.redisOption),
// 	secret:config.sessionOption.secret,
// 	resave:config.sessionOption.resave,
// 	saveUninitialized:config.sessionOption.saveUninitialized
// }));



/*==配置设置====================*/
app.set('views',path.join(__dirname,"views"));
app.engine('.html', require('ejs').renderFile);//注册HTML扩展名的模板
app.set('view engine', 'html');





/*==监听接口=============*/
app.listen('8080');